<div class="widget">
	<div class="widget-header bg-blue">
		<i class="widget-icon icon-notebook"></i> 
		<span class="widget-caption"> 系统通知 </span>
		<div class="widget-buttons">
			<a href="javascript:void(0);" onclick="handlerCancel(this);" title="关闭"
				 data-toggle="dispose" data-refresh-table="#table-notify"> <i class="fa fa-times"></i> </a> 
		</div>
	</div>
	<div class="widget-body">
		<!-- TODO 基本信息 -->
		<div class="widget radius-bordered">
			<div class="widget-header">
				<i class="widget-icon icon-notebook"></i> 
				<span class="widget-caption"> 基本信息 </span>
			</div>
			<div class="widget-body editor-body-sm">
				<form class="form-horizontal form-editor form-editor-notify">
					<div class="row">
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-3 control-label required" for="title">标题</label>
								<div class="col-sm-9">
									<select name="title" id="title" class="chosen-select" data-url="/miwawa/default/common/select.json" data-pcode="c_notify_title" data-entity="com.app.miwawa.api.system.entity.config.Codec">
									</select>
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-3 control-label required" for="icon">图标</label>
								<div class="col-sm-9">
									<div class="input-group">
							      <input name="icon" id="icon" class="form-control" value="fa fa-bell" aria-label="...">
							      <div class="input-group-btn">
							        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">选择 <span class="caret"></span></button>
							        <ul class="dropdown-menu dropdown-menu-right">
							          <li><a href="javascript:void(0);" onclick="handlerIcon('fa fa-bell');"><i class="icon fa fa-bell"></i> fa-bell</a></li>
										    <li><a href="javascript:void(0);" onclick="handlerIcon('fa fa-envelope');"><i class="icon fa fa-envelope"></i> fa-envelope</a></li>
										    <li><a href="javascript:void(0);" onclick="handlerIcon('fa fa-commenting');"><i class="icon fa fa-commenting"></i> fa-commenting</a></li>
										    <li><a href="javascript:void(0);" onclick="handlerIcon('fa fa-exclamation');"><i class="icon fa fa-exclamation"></i> fa-exclamation </a></li>
							        </ul>
							      </div>
							    </div>
								</div>
							</div>
						</div>
						<div class="col-sm-4">
							<div class="form-group">
								<label class="col-sm-3 control-label" for="createDate">通知时间</label>
								<div class="col-sm-9">
									<div class="input-group date date-selector">
										<input name="createDate" id="createDate" type="text" class="form-control"> 
										<span class="input-group-addon">
											<span class="fa fa-calendar"></span>
										</span>
									</div>
								</div>
							</div>
						</div>
					</div>
					
					<div class="row">
						<div class="col-sm-12">
							<div class="widget">
								<div class="widget-header bordered-top bordered-pink">
									<span class="widget-caption"> 通知内容 </span>
								</div>
								<div class="widget-body">
									<textarea id="message" name="message" class="form-control">系统将于今晚18:00下线更新！</textarea>
								</div>
							</div>
						</div>
						
						<div class="col-sm-12">
							<div class="widget">
								<div class="widget-header bordered-top bordered-pink">
									<span class="widget-caption"> 通知备注 </span>
								</div>
								<div class="widget-body">
									<textarea id="info" name="info" class="form-control">更新时间大约为1小时，请耐心等待！</textarea>
								</div>
							</div>
						</div>
						
						<div class="col-sm-12">
							<div class="widget">
								<div class="widget-header bordered-top bordered-pink">
									<span class="widget-caption"> 备注附件 </span>
								</div>
								<div class="widget-body">
									<input id="upload" name="file" type="file" class="file" data-show-preview="false" multiple>
								</div>
							</div>
						</div>
					</div>
					
					<div class="widget-footer editor-footer-sm">
						<button type="button" class="btn btn-danger btn-sm" data-toggle="tooltip" data-placement="top" title="取消" onclick="handlerCancel(this);" data-refresh-table="#table-notify">
							<i class="glyphicon glyphicon-remove"></i>
						</button>
						<button type="button" class="btn btn-primary btn-sm" data-toggle="tooltip" data-placement="top" title="保存并发布" onclick="handlerSubmit(this, '#editor-form-notify', '.form-editor-notify');">
							<i class="glyphicon glyphicon-ok"></i>
						</button>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<!-- 提交表单 ========================================================= -->
<form id="editor-form-notify" action="/miwawa/message/send" method="post" 
			name="org.framework.common.api.entity.CommonMessage" data-custom-action="true">
			<input type="hidden" name="userid">
			<input type="hidden" name="username">
			<input type="hidden" name="status" value="0">
			<input type="hidden" name="invalid" value="F">
</form>
    
<script type="text/javascript">
<!--
	jQuery(function() {
		jQuery(":hidden[name='userid']","#editor-form-notify").val(userid);
		jQuery(":hidden[name='username']","#editor-form-notify").val(username);
		
		require(['jquery.plugin.form'],function(form){
			form.datepicker('.date-selector',{format:'YYYY-MM-DD HH:mm:ss'});
			form.tooltip("[data-toggle='tooltip']");
			form.chosen("#title").select("#title",null,function(chosen){
				chosen.on('change', function(event, params) {
					handlerChange(params.selected);
			  });
			});
		});
		
		registerUpload();
	});
	
	// 选择标题
	function handlerChange(title){
		switch(title){
			case "系统下线通知":
				jQuery("#message").html("系统将于今晚18:00下线更新！");
				jQuery("#info").html("更新时间大约为1小时，请耐心等待！");
			break;
			case "系统更新通知":
				jQuery("#message").html("系统功能已更新！");
				jQuery("#info").html("点击查看详情");
			break;
		}
	}
	
	// 选择图标
	function handlerIcon(icon){
		jQuery("#icon").val(icon)
	}
	
	// 注册上传控件
	function registerUpload(){
		require(['jquery.plugin.form'],function(form){
			// 注册文件上传控件
			form.fileinput("#upload", { 
				uploadUrl:"/miwawa/{dbname}/file/upload".replace("{dbname}","default"),
				uploadExtraData: {
					"notsaved": true,
					"group"		: "message",
					"mode"		: "file"
				},
				allowedFileExtensions: ["html"],
				onUploadSuccess:function(event, data, previewId, index){
					jQuery("#info").html("<a data-toggle='modal' data-target='#common-modal' data-url='"+data.response.url+"'>点击查看详情</a>");
				}
			});
		});
	}
	
//-->
</script>